import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '发货时间',
    align:"center",
    dataIndex: 'consignTime',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '原始订单号',
    align:"center",
    dataIndex: 'srcTid'
   },
  //  {
  //   title: '货品名称',
  //   align:"center",
  //   dataIndex: 'goodsName'
  //  },
   {
    title: '货品编码',
    align:"center",
    dataIndex: 'goodsNo'
   },
   {
    title: '分类',
    align:"center",
    dataIndex: 'className'
   },
  //  {
  //   title: '出库单id',
  //   align:"center",
  //   dataIndex: 'stockoutId'
  //  },
  //  {
  //   title: '出库单详情id',
  //   align:"center",
  //   dataIndex: 'recId'
  //  },
  //  {
  //   title: '订单明细id',
  //   align:"center",
  //   dataIndex: 'srcOrderDetailId'
  //  },
  //  {
  //   title: '出单号',
  //   align:"center",
  //   dataIndex: 'orderNo'
  //  },
  //  {
  //   title: '商家编码',
  //   align:"center",
  //   dataIndex: 'specNo'
  //  },
   {
    title: '货品数量',
    align:"center",
    dataIndex: 'goodsCount'
   },
  //  {
  //   title: '总成本',
  //   align:"center",
  //   dataIndex: 'totalAmount'
  //  },
   {
    title: '已付',
    align:"center",
    dataIndex: 'paid'
   },
  //  {
  //   title: '出库单明细备注',
  //   align:"center",
  //   dataIndex: 'remark'
  //  },
  
  //  {
  //   title: '货品数量',
  //   align:"center",
  //   dataIndex: 'num'
  //  },
   {
    title: '创建时间',
    align:"center",
    dataIndex: 'createdDate',
    customRender:({text}) =>{
      // text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
  
   {
    title: '客服备注',
    align:"center",
    dataIndex: 'csRemark'
   },
   {
    title: '大区',
    align:"center",
    dataIndex: 'region'
   },
   {
    title: '业务员',
    align:"center",
    dataIndex: 'salesUser'
   },
   {
    title: '公司名称',
    align:"center",
    dataIndex: 'company'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "创建时间",
      field: "createdDate",
      component: 'RangePicker',
      componentProps: {
        valueType: 'Date',
      },
      //colProps: {span: 6},
	},
     {
      label: "发货时间",
      field: "consignTime",
      component: 'RangePicker',
      componentProps: {
        valueType: 'Date',
      },
      //colProps: {span: 6},
	},
	{
      label: "大区",
      field: 'region',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "业务员",
      field: 'salesUser',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '出库单id',
    field: 'stockoutId',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入出库单id!'},
          ];
     },
  },
  {
    label: '出库单详情id',
    field: 'recId',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入出库单详情id!'},
          ];
     },
  },
  {
    label: '订单明细id',
    field: 'srcOrderDetailId',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入订单明细id!'},
          ];
     },
  },
  {
    label: '出单号',
    field: 'orderNo',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入出单号!'},
          ];
     },
  },
  {
    label: '商家编码',
    field: 'specNo',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入商家编码!'},
          ];
     },
  },
  {
    label: '货品数量',
    field: 'goodsCount',
    component: 'InputNumber',
  },
  {
    label: '总成本',
    field: 'totalAmount',
    component: 'InputNumber',
  },
  {
    label: '成交价',
    field: 'sellPrice',
    component: 'InputNumber',
  },
  {
    label: '出库单明细备注',
    field: 'remark',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入出库单明细备注!'},
          ];
     },
  },
  {
    label: '货品名称',
    field: 'goodsName',
    component: 'Input',
  },
  {
    label: '货品编码',
    field: 'goodsNo',
    component: 'Input',
  },
  {
    label: '规格名称',
    field: 'specName',
    component: 'Input',
  },
  {
    label: '规格码',
    field: 'specCode',
    component: 'Input',
  },
  {
    label: '货品成本',
    field: 'costPrice',
    component: 'InputNumber',
  },
  {
    label: '总重量',
    field: 'weight',
    component: 'InputNumber',
  },
  {
    label: '单价/货品原单价',
    field: 'marketPrice',
    component: 'InputNumber',
  },
  {
    label: '货品成交价',
    field: 'sharePrice',
    component: 'InputNumber',
  },
  {
    label: '原始子订单号',
    field: 'srcOid',
    component: 'Input',
  },
  {
    label: '原始订单号',
    field: 'srcTid',
    component: 'Input',
  },
  {
    label: '货品数量',
    field: 'num',
    component: 'InputNumber',
  },
  {
    label: '发货时间',
    field: 'consignTime',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
  },
  
  {
    label: '大区',
    field: 'region',
    component: 'Input',
  },
  {
    label: '业务员',
    field: 'salesUser',
    component: 'Input',
  },
  {
    label: '公司名称',
    field: 'company',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  stockoutId: {title: '出库单id',order: 0,view: 'number', type: 'number',},
  recId: {title: '出库单详情id',order: 1,view: 'number', type: 'number',},
  srcOrderDetailId: {title: '订单明细id',order: 2,view: 'number', type: 'number',},
  orderNo: {title: '出单号',order: 3,view: 'text', type: 'string',},
  specNo: {title: '商家编码',order: 4,view: 'text', type: 'string',},
  goodsCount: {title: '货品数量',order: 5,view: 'number', type: 'number',},
  totalAmount: {title: '总成本',order: 6,view: 'number', type: 'number',},
  sellPrice: {title: '成交价',order: 7,view: 'number', type: 'number',},
  remark: {title: '出库单明细备注',order: 8,view: 'text', type: 'string',},
  goodsName: {title: '货品名称',order: 9,view: 'text', type: 'string',},
  goodsNo: {title: '货品编码',order: 10,view: 'text', type: 'string',},
  specName: {title: '规格名称',order: 11,view: 'text', type: 'string',},
  specCode: {title: '规格码',order: 12,view: 'text', type: 'string',},
  costPrice: {title: '货品成本',order: 13,view: 'number', type: 'number',},
  weight: {title: '总重量',order: 14,view: 'number', type: 'number',},
  marketPrice: {title: '单价/货品原单价',order: 15,view: 'number', type: 'number',},
  sharePrice: {title: '货品成交价',order: 16,view: 'number', type: 'number',},
  srcOid: {title: '原始子订单号',order: 17,view: 'text', type: 'string',},
  srcTid: {title: '原始订单号',order: 18,view: 'text', type: 'string',},
  num: {title: '货品数量',order: 19,view: 'number', type: 'number',},
  createdDate: {title: '创建时间',order: 20,view: 'date', type: 'string',},
  consignTime: {title: '发货时间',order: 21,view: 'date', type: 'string',},
  region: {title: '大区',order: 22,view: 'text', type: 'string',},
  salesUser: {title: '业务员',order: 23,view: 'text', type: 'string',},
  company: {title: '公司名称',order: 24,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}